
<?php
class Solution {

    /**
     * @param Integer[] $nums1
     * @param Integer[] $nums2
     * @return Float
     */
    function findMedianSortedArrays($nums1, $nums2) {
        $merge_arr = array_merge($nums1, $nums2);
        sort($merge_arr);
        
        //偶数
        if( count($merge_arr)%2 == 0){
            //echo $merge_arr[count($merge_arr)/2-1];
            $mid = ($merge_arr[count($merge_arr)/2-1]+$merge_arr[count($merge_arr)/2])/2;
        }else{
            //echo 22;
            $mid = $merge_arr[ceil(count($merge_arr)/2)-1];
        }
        return $mid;
    }
}

$obj = new Solution();
//$nums1 = [1,3];$nums2 = [2];
$nums1 = [1,2];$nums2 = [3,4];
//$nums1 = [0,0]; $nums2 = [0,0];
//$nums1 = []; $nums2 = [1];
//$nums1 = [2]; $nums2 = [];
$nums1 = [100000];$nums2 = [100001];
$rst = $obj->findMedianSortedArrays($nums1, $nums2);
echo $rst;